package com.mouse.hxsj;

import com.mouse.hxsj.constants.ComPool;
import com.mouse.hxsj.constants.SystemParams;
import com.mouse.hxsj.util.JsonUtil;
import com.mouse.hxsj.view.MainFrm;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ApplicationContext;


@Slf4j
@MapperScan("com.mouse.hxsj.dao")
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class);
        ApplicationContext applicationContext = builder.headless(false).run(args);
        MainFrm mainFrm = applicationContext.getBean(MainFrm.class);
        mainFrm.setVisible(true);
        init();
        initSystemParam(args);
    }

    private static void init() {
        ComPool.init();
    }

    private static void initSystemParam(String[] args) {
        log.info("输入参数:{}", JsonUtil.toJson(args));
        if (args == null || args.length == 0) return;
        //自动验证码
        if (args.length >= 1) {
            String autoYzmFlag = args[0];
            if ("false".equalsIgnoreCase(autoYzmFlag)) SystemParams.autoYzm = false;
        }
    }
}
